#include "../gba_types.h"
#include "../fe8.h"

typedef struct{
    void* data;
    void* pal;
}mini_portrait_t;

#define tile_data_head \
    0x0,    \
    ((32*32)>>1) & 0xff, \
    (((32*32)>>1)>>8) & 0xff, \
    0,
#include "data.h"

#include "../hack/mini_portrait_data.h"



const mini_portrait_t mini_portrait_data[0x100] = {
    //[2] = {tile_data,agb_pal},
#include "../hack/mini_portrait_def.h"
};

void JMP800582C_r3(u32 a1,u32 a2,u32 a3){
    if(a1<=0x7eff){
        //a1 = 2;
        u32 *v = (u32*)CALLT(0x800541C,a1); //获得肖像数据
        if(!mini_portrait_data[a1].data){
            CALLT(0x8013008,v[1],32*a2+0x6000000);
        }
        else{
            CALLT(0x8013008,mini_portrait_data[a1].data,32*a2+0x6000000);
        }
        if(!mini_portrait_data[a1].pal){
            CALLT(0x8000D68,v[2],32*a3,0x20);
        }
        else{
            CALLT(0x8000D68,mini_portrait_data[a1].pal,32*a3,0x20);
        }
    }
    else{
        u32 *v = (u32*)CALLT(0x8005E70,a1);
        CALLT(0x8001F64,v,((32*a2+0x06000000)&0x1ffff)+0x06000000,0x200);
        CALLT(0x8005EA0,a1,a3);
    }
}
